<?php
ini_set("display_errors" ,0);
my_component_load('testing' , false);
my_component_load('paging' , false);   
my_component_load('data_setting', false);
my_component_load('list_kalender' , false);   
my_component_load('pr_insentif' );
$task = isset($_GET['task']) ? $_GET['task'] : "";  
$tanggal = isset($_GET['tanggal']) ? $_GET['tanggal'] : "";  
$value = isset($_GET['value']) ? $_GET['value'] : "";  
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;

$modulname = "Penggajian _BN_ Insentif";
if($_SERVER['REQUEST_METHOD'] == "POST" ):
	if($task=='edit_page'){
		$validatepost = insentif_validate($id);
		if($validatepost){
			$errors = message_multi_error($validatepost);
			$content = $errors;
			$content .= form_insentif($id);
			generate_my_web($content,"","plain.php");
			exit; 
		}else {
			submit_insentif($id); 
			$content =  "Updated";
			generate_my_web($content,"","plain.php");
			exit;
		}
		break; 	
	}
	my_direct('index.php?com=pr_insentif');
	break;	
else: 
	if($task == "create"){
		facebox_page( 'index.php?com='.$_GET['com'].'&task=detail_kelompok_page&periode_id='.$_GET['periode_id'].'&kelompok_shift_id='.$_GET['kelompok_shift_id'],  ' ', 420	);
	}elseif($task == "detail_kelompok_page"){
			$pagename = $modulname." _BN_ Detail _BN_ Setting Jadwal Kerja";
			$view =  detail_kelompok_shift($periode_id ,$kelompok_shift_id);
			generate_my_web($view,"","plain.php");
			exit;				

	}elseif($task =="update"){
			update_tanggal_shift($tanggal , $periode_id , $kelompok_shift_id , $value);
			my_direct($_SERVER['HTTP_REFERER']);
			break;
	}elseif($task == 'create_schedule'){ 
			form_generate_kalender_shift() ;
			my_direct($_SERVER['HTTP_REFERER']);
			break;
	}elseif($task =="detail"){
			load_facebox_script();
			$pagename = $modulname." _BN_ Detail";
			$view =  list_karyawan($id);
							
	}elseif($task == "edit"){ 
		$pagename = ($id > 0 ) ? "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=pr_insentif&task=edit_page&id='.$id , $pagename , 260	);
	}elseif($task == "edit_page"){
		ini_set("max_execution_time","10000");	
		$content = form_insentif($id);
		generate_my_web($content, '' ,"plain.php");
		exit;			
	}elseif($task == 'delete'){ 
		delete_insentif($id);
		my_direct('index.php?com=pr_insentif');
	}elseif($task =='loadpage'){
		$title="Proses Insentif";
		facebox_page('index.php?com='.$_GET['com'].'&id='.$id.'&task=vpage&p='.rand(0,999999) , $title , 120	); 
	}elseif($task =='vpage'){
		$content = page_kalkulasi_insentif(); 
		generate_my_web($content,"","plain.php");
		exit;
	}elseif($task == 'proses'){ 
		update_insentif_karyawan($id) ;
		echo button_icon( 'check2.png' ,'')."<br/>Done !!";
		exit;
	}elseif($task == "plaincetak"){
		@ob_end_clean(); 
		echo'<pre>';
		echo print_plain($id);
		exit;
	}elseif($task == "excel"){
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment;filename=insentif".rand().".xls");
		echo excel_report($id);
		exit;		
	}else{
			$pagename = $modulname;
			load_facebox_script();
			$view =  list_insentif();
			$href = 'index.php?com=pr_insentif&task=create' ;
	}
	generate_my_web($view , $pagename );	
endif; 


